package com.java.dp.singleton;

/**
 * @Author lizhilong
 * @create 2019/12/2 13:57
 * @desc 单例模式的特点：全局只有一个实例，实例必须由单例自己创造，提供一个入口获取实例
 */
public class Singleton {

    private volatile static Singleton instance;

    private Singleton() {

    }

    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    return new Singleton();
                }
            }
        }
        return instance;
    }
}
